﻿using RishCenter.HttpApi.Client;

namespace DDDDemo2;

public class BusiSafeService : IBusiSafeService
{
    private readonly RishCheckService _RiskCheckService;

    public BusiSafeService(RishCheckService rishCheckService)
    {
        _RiskCheckService = rishCheckService;
    }

    public async Task<BusiSafeStatus> CheckBusiAsync(
        Guid userId,
        string merchantAccountNo,
        decimal amount)
    {
        var rishCode = await _RiskCheckService.CheckPaymentAsync(userId, merchantAccountNo, amount);
        if (!"0000".Equals(rishCode))
        {
            return BusiSafeStatus.Success;
        }
        return BusiSafeStatus.Reject;
    }
}
